package Thread;
class MyThread extends Thread{
    @Override
    public void run() {
        //这里就是即将创建线程,要执行的逻辑
        while (true) {
            System.out.println("hello,Thread!");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }
    }
}

public class Demo1 {
    public static void main(String[] args) throws InterruptedException {
        MyThread t = new MyThread();
        //创建线程
        t.start();

        //t.run();
        //run没有创建新线程
        while (true){
            System.out.println("hello,main!");
            Thread.sleep(1000);
        }
    }

}
